<?php
class Tips
{
	public static function success($text, $url = false, $dec = '2')
	{
		$content =  '
            <!doctype html>
            <html>
            <head>
            <meta charset="utf-8">
            <title>'.$text.'</title>
            <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
            </head>
            <body>
                <div class="container" style="margin-top:9%;">
                    <div class="panel panel-success">
                        <div class="panel-heading" style="text-align:center;"><h1>'.$text.'</h1></div>
                    </div>
                </div>
            </body>
            </html>
        ';
		if($url){
			$content .= '<script>setTimeout(function (){location.href = "'.$url.'"},'.$dec.'000);</script>';
		}
		exit($content);
	}
	public static function error($text, $url = false, $dec = '2')
	{
		$content =  '
            <!doctype html>
            <html>
            <head>
            <meta charset="utf-8">
            <title>'.$text.'</title>
            <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
            </head>
            <body>
                <div class="container" style="margin-top:9%;">
                    <div class="panel panel-danger">
                        <div class="panel-heading" style="text-align:center;"><h1>'.$text.'</h1></div>
                    </div>
                </div>
            </body>
            </html>
        ';
		if($url){
			$content .= '<script>setTimeout(function (){location.href = "'.$url.'"},'.$dec.'000);</script>';
		}
		exit($content);
	}
}
class Gets
{
	public static function pay($DB, $out_trade_no)
	{
		return $DB->query("SELECT * FROM `impepd_pay` WHERE `out_trade_no` = '$out_trade_no'")->fetch(PDO::FETCH_ASSOC);
	}
	public static function ip()
	{
		if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
			$ip = getenv('HTTP_CLIENT_IP');
		} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
			$ip = getenv('HTTP_X_FORWARDED_FOR');
		} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
			$ip = getenv('REMOTE_ADDR');
		} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
			$ip = $_SERVER['REMOTE_ADDR'];
		}
		return preg_match ( '/[\d\.]{7,15}/', $ip, $matches ) ? $matches [0] : '';
	}
}